<!doctype html>



  


<html class="theme-next mist use-motion">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>



<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />



  <meta name="google-site-verification" content="phvIxhLnoRK2eQ9tXOLvw-8iE1H0mFo4GgW6Z--EPaU" />










  
  
  <link href="/vendors/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />




  
  
  
  

  
    
    
  

  

  

  

  
    
      
    

    
  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic|PT Mono:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/vendors/font-awesome/css/font-awesome.min.css?v=4.4.0" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.0.2" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="Android,Giraffe,vector," />








  <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico?v=5.0.2" />






<meta name="description" content="使用 Android Studio 内置的 vector 生成图标的兼容问题 详细查看该原作者的博客 Giraffe 项目地址
Giraffe 项目中的使用首先说一下不兼容的问题，如果直接使用 vector ，图标也会展现出来，但是无论你在 vector 中设置的颜色是什么，都会显示为黑色的。
&amp;lt;vector xmlns:android=&amp;quot;http://schemas.androi">
<meta property="og:type" content="article">
<meta property="og:title" content="项目 Giraffe 记事本之使用 vector 生成图标的兼容问题">
<meta property="og:url" content="http://junaya.cn/2016/11/24/项目 Giraffe 记事本之使用 vector 生成图标的兼容问题/index.html">
<meta property="og:site_name" content="JunaYa 个人博客">
<meta property="og:description" content="使用 Android Studio 内置的 vector 生成图标的兼容问题 详细查看该原作者的博客 Giraffe 项目地址
Giraffe 项目中的使用首先说一下不兼容的问题，如果直接使用 vector ，图标也会展现出来，但是无论你在 vector 中设置的颜色是什么，都会显示为黑色的。
&amp;lt;vector xmlns:android=&amp;quot;http://schemas.androi">
<meta property="og:updated_time" content="2016-11-25T17:32:00.000Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="项目 Giraffe 记事本之使用 vector 生成图标的兼容问题">
<meta name="twitter:description" content="使用 Android Studio 内置的 vector 生成图标的兼容问题 详细查看该原作者的博客 Giraffe 项目地址
Giraffe 项目中的使用首先说一下不兼容的问题，如果直接使用 vector ，图标也会展现出来，但是无论你在 vector 中设置的颜色是什么，都会显示为黑色的。
&amp;lt;vector xmlns:android=&amp;quot;http://schemas.androi">



<script type="text/javascript" id="hexo.configuration">
  var NexT = window.NexT || {};
  var CONFIG = {
    scheme: 'Mist',
    sidebar: {"position":"right","display":"post"},
    fancybox: true,
    motion: true,
    duoshuo: {
      userId: '0',
      author: '博主'
    }
  };
</script>




  <link rel="canonical" href="http://junaya.cn/2016/11/24/项目 Giraffe 记事本之使用 vector 生成图标的兼容问题/"/>


  <title> 项目 Giraffe 记事本之使用 vector 生成图标的兼容问题 | JunaYa 个人博客 </title>
</head>

<body itemscope itemtype="//schema.org/WebPage" lang="zh-Hans">

  


<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
            (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
          m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
  ga('create', 'UA-75987543-1', 'auto');
  ga('send', 'pageview');
</script>


  <script type="text/javascript">
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "//hm.baidu.com/hm.js?cc7b51117960f696b7b7b77ef8425406";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>








  
  
    
  

  <div class="container one-collumn sidebar-position-right page-post-detail ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="//schema.org/WPHeader">
      <div class="header-inner"><div class="site-meta custom-logo">
  

  <div class="custom-logo-site-title">
    <a href="/"  class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <span class="site-title">JunaYa 个人博客</span>
      <span class="logo-line-after"><i></i></span>
    </a>
  </div>
  <p class="site-subtitle"></p>
</div>

<div class="site-nav-toggle">
  <button>
    <span class="btn-bar"></span>
    <span class="btn-bar"></span>
    <span class="btn-bar"></span>
  </button>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            所有文章
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-navicon"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/about" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br />
            
            关于
          </a>
        </li>
      

      
        <li class="menu-item menu-item-search">
          
            <a href="javascript:;" class="popup-trigger">
          
            
              <i class="menu-item-icon fa fa-search fa-fw"></i> <br />
            
            搜索
          </a>
        </li>
      
    </ul>
  

  
    <div class="site-search">
      
  <div class="popup">
 <span class="search-icon fa fa-search"></span>
 <input type="text" id="local-search-input">
 <div id="local-search-result"></div>
 <span class="popup-btn-close">close</span>
</div>


    </div>
  
</nav>

 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  
  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="//schema.org/Article">

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
            
            
              
                项目 Giraffe 记事本之使用 vector 生成图标的兼容问题
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">
            <span class="post-meta-item-icon">
              <i class="fa fa-calendar-o"></i>
            </span>
            <span class="post-meta-item-text">发表于</span>
            <time itemprop="dateCreated" datetime="2016-11-24T21:33:10+08:00" content="2016-11-24">
              2016-11-24
            </time>
          </span>

          

          
            
              <span class="post-comments-count">
                &nbsp; | &nbsp;
                <a href="/2016/11/24/项目 Giraffe 记事本之使用 vector 生成图标的兼容问题/#comments" itemprop="discussionUrl">
                  <span class="post-comments-count disqus-comment-count" data-disqus-identifier="2016/11/24/项目 Giraffe 记事本之使用 vector 生成图标的兼容问题/" itemprop="commentsCount"></span>
                </a>
              </span>
            
          

          

          
          

          
        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        <h1 id="使用-Android-Studio-内置的-vector-生成图标的兼容问题"><a href="#使用-Android-Studio-内置的-vector-生成图标的兼容问题" class="headerlink" title="使用 Android Studio 内置的 vector 生成图标的兼容问题"></a>使用 Android Studio 内置的 vector 生成图标的兼容问题</h1><p> <a href="http://blog.csdn.net/u010335298/article/details/51840805" target="_blank" rel="external">详细查看该原作者的博客</a><br> <a href="https://github.com/JunaYa/Giraffe" target="_blank" rel="external">Giraffe 项目地址</a></p>
<h2 id="Giraffe-项目中的使用"><a href="#Giraffe-项目中的使用" class="headerlink" title="Giraffe 项目中的使用"></a>Giraffe 项目中的使用</h2><p>首先说一下不兼容的问题，如果直接使用 vector ，图标也会展现出来，但是无论你在 vector 中设置的颜色是什么，都会显示为黑色的。</p>
<pre><code>&lt;vector xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
    android:width=&quot;24dp&quot;
    android:height=&quot;24dp&quot;
    android:viewportWidth=&quot;24.0&quot;
    android:viewportHeight=&quot;24.0&quot;&gt;
&lt;path
    android:fillColor=&quot;@color/white&quot;
    android:pathData=&quot;M19,13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z&quot;/&gt;
</code></pre><p></p>
<p>例如上面代码中给 path 设置 android:fillColor=”@color/white” ，即使你设置为白色，但在 5.0 一下依然显示为黑色。<br>使用兼容就可以实现颜色的设置</p>
<p>使用Gradle Plugin 2.0以上</p>
<pre><code>defaultConfig {
    vectorDrawables.useSupportLibrary = true
}
</code></pre><p>然后在 BaseActivity 中统一添加</p>
<pre><code>static {
    AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
}
</code></pre><p>如果 ImageView 使用 src 来使用该文件，</p>
<pre><code>&lt;ImageView
    android:id=&quot;@+id/iv&quot;
    android:layout_width=&quot;wrap_content&quot;
    android:layout_height=&quot;wrap_content&quot;
    app:srcCompat=&quot;@drawable/vector_image&quot;/&gt;
</code></pre><p>如果设置背景 例如给 ImageButton</p>
<pre><code>&lt;ImageButton
    android:id=&quot;@+id/tags&quot;
    android:layout_width=&quot;28dp&quot;
    android:layout_height=&quot;28dp&quot;
    android:layout_alignParentRight=&quot;true&quot;
    android:layout_centerVertical=&quot;true&quot;
    android:padding=&quot;8dp&quot;
    android:gravity=&quot;center&quot;
    android:button=&quot;@null&quot;
    android:background=&quot;@drawable/ic_add&quot;
    android:onClick=&quot;@{viewModel.onAddType}&quot;
    android:text=&quot;@string/tags&quot;/&gt;
</code></pre><p>其中 android:background=”@drawable/ic_add” 是</p>
<pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;selector xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;&gt;
    &lt;item android:drawable=&quot;@drawable/ic_add_normal&quot; android:state_pressed=&quot;false&quot;/&gt;
    &lt;item android:drawable=&quot;@drawable/ic_add_pressed&quot; android:state_pressed=&quot;true&quot;/&gt;
&lt;/selector&gt;
</code></pre><p>而其中 ic_add_normal 和 ic_add_pressed 的事件颜色不同</p>
<pre><code>&lt;vector xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
    android:width=&quot;24dp&quot;
    android:height=&quot;24dp&quot;
    android:viewportWidth=&quot;24.0&quot;
    android:viewportHeight=&quot;24.0&quot;&gt;
&lt;path
    android:fillColor=&quot;@color/white&quot;
    android:pathData=&quot;M19,13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z&quot;/&gt;
&lt;/vector&gt;
</code></pre><p>如果直接把文件 ic_add_normal 直接设置给会有如下错误</p>
<pre><code>Caused by: android.view.InflateException: Binary XML file line #58: Error inflating class Button
</code></pre><p>所以，必须要包裹一下 vector 文件。</p>

      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        

      
    </div>

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/Android/" rel="tag">#Android</a>
          
            <a href="/tags/Giraffe/" rel="tag">#Giraffe</a>
          
            <a href="/tags/vector/" rel="tag">#vector</a>
          
        </div>
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2016/11/20/OOM之Giraffe-记事本中使用ClipboardManager不当/" rel="next" title="OOM之Giraffe 记事本中使用ClipboardManager不当">
                <i class="fa fa-chevron-left"></i> OOM之Giraffe 记事本中使用ClipboardManager不当
              </a>
            
          </div>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2016/11/26/TextSwitcher-遇到的坑/" rel="prev" title="TextSwitcher 遇到的坑">
                TextSwitcher 遇到的坑 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </article>



    <div class="post-spread">
      
        <!-- JiaThis Button BEGIN -->
<div class="jiathis_style">
  <a class="jiathis_button_tsina"></a>
  <a class="jiathis_button_tqq"></a>
  <a class="jiathis_button_weixin"></a>
  <a class="jiathis_button_cqq"></a>
  <a class="jiathis_button_douban"></a>
  <a class="jiathis_button_renren"></a>
  <a class="jiathis_button_qzone"></a>
  <a class="jiathis_button_kaixin001"></a>
  <a class="jiathis_button_copy"></a>
  <a href="http://www.jiathis.com/share" class="jiathis jiathis_txt jiathis_separator jtico jtico_jiathis" target="_blank"></a>
  <a class="jiathis_counter_style"></a>
</div>
<script type="text/javascript" >
  var jiathis_config={
    hideMore:false
  }
</script>
<script type="text/javascript" src="http://v3.jiathis.com/code/jia.js" charset="utf-8"></script>
<!-- JiaThis Button END -->

      
    </div>
  </div>


          </div>
          


          
  <div class="comments" id="comments">
    
      <div id="disqus_thread">
        <noscript>
          Please enable JavaScript to view the
          <a href="//disqus.com/?ref_noscript">comments powered by Disqus.</a>
        </noscript>
      </div>
    
  </div>


        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap" >
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview sidebar-panel ">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="//schema.org/Person">
          <img class="site-author-image" itemprop="image"
               src="/images/avatar.jpg"
               alt="JunaYa" />
          <p class="site-author-name" itemprop="name">JunaYa</p>
          <p class="site-description motion-element" itemprop="description">格物致知</p>
        </div>
        <nav class="site-state motion-element">
          <div class="site-state-item site-state-posts">
            <a href="/archives">
              <span class="site-state-item-count">15</span>
              <span class="site-state-item-name">日志</span>
            </a>
          </div>

          
            <div class="site-state-item site-state-categories">
              <a href="/categories">
                <span class="site-state-item-count">1</span>
                <span class="site-state-item-name">分类</span>
              </a>
            </div>
          

          
            <div class="site-state-item site-state-tags">
              <a href="/tags">
                <span class="site-state-item-count">22</span>
                <span class="site-state-item-name">标签</span>
              </a>
            </div>
          

        </nav>

        

        <div class="links-of-author motion-element">
          
            
              <span class="links-of-author-item">
                <a href="https://github.com/" target="_blank" title="GitHub">
                  
                    <i class="fa fa-fw fa-github"></i>
                  
                  GitHub
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="http://weibo.com/u/2970747693/home?topnav=1&wvr=6" target="_blank" title="微博">
                  
                    <i class="fa fa-fw fa-globe"></i>
                  
                  微博
                </a>
              </span>
            
          
        </div>

        
        

        
        
          <div class="links-of-blogroll motion-element links-of-blogroll-inline">
            <div class="links-of-blogroll-title">
              <i class="fa  fa-fw fa-globe"></i>
              
            </div>
            <ul class="links-of-blogroll-list">
              
                <li class="links-of-blogroll-item">
                  <a href="https://drakeet.me/" title="drakeet" target="_blank">drakeet</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="http://blog.zhaiyifan.cn/" title="markzhai" target="_blank">markzhai</a>
                </li>
              
            </ul>
          </div>
        

      </section>

      
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">
            
              
            
            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#使用-Android-Studio-内置的-vector-生成图标的兼容问题"><span class="nav-number">1.</span> <span class="nav-text">使用 Android Studio 内置的 vector 生成图标的兼容问题</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#Giraffe-项目中的使用"><span class="nav-number">1.1.</span> <span class="nav-text">Giraffe 项目中的使用</span></a></li></ol></li></ol></div>
            
          </div>
        </section>
      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy; 
  <span itemprop="copyrightYear">2016</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">JunaYa</span>
</div>

<div class="powered-by">
  由 <a class="theme-link" href="https://hexo.io">Hexo</a> 强力驱动
</div>

<div class="theme-info">
  主题 -
  <a class="theme-link" href="https://github.com/iissnan/hexo-theme-next">
    NexT.Mist
  </a>
</div>

        

        
      </div>
    </footer>

    <div class="back-to-top">
      <i class="fa fa-arrow-up"></i>
    </div>
  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  



  
  <script type="text/javascript" src="/vendors/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/vendors/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/vendors/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/vendors/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/vendors/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/vendors/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.0.2"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.0.2"></script>



  
  

  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.0.2"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.0.2"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.0.2"></script>



  



  

    <script type="text/javascript">
      var disqus_shortname = 'junaya';
      var disqus_identifier = '2016/11/24/项目 Giraffe 记事本之使用 vector 生成图标的兼容问题/';
      var disqus_title = "项目 Giraffe 记事本之使用 vector 生成图标的兼容问题";
      var disqus_url = 'http://junaya.cn/2016/11/24/项目 Giraffe 记事本之使用 vector 生成图标的兼容问题/';

      function run_disqus_script(disqus_script){
        var dsq = document.createElement('script');
        dsq.type = 'text/javascript';
        dsq.async = true;
        dsq.src = '//' + disqus_shortname + '.disqus.com/' + disqus_script;
        (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
      }

      run_disqus_script('count.js');
      
        var disqus_config = function () {
            this.page.url = disqus_url;
            this.page.identifier = disqus_identifier;
            this.page.title = disqus_title;
        };
        run_disqus_script('embed.js');
      
    </script>
  




  
  
  <script type="text/javascript">
    // Popup Window;
    var isfetched = false;
    // Search DB path;
    var search_path = "search.xml";
    if (search_path.length == 0) {
       search_path = "search.xml";
    }
    var path = "/" + search_path;
    // monitor main search box;

    function proceedsearch() {
      $("body").append('<div class="popoverlay">').css('overflow', 'hidden');
      $('.popup').toggle();

    }
    // search function;
    var searchFunc = function(path, search_id, content_id) {
    'use strict';
    $.ajax({
        url: path,
        dataType: "xml",
        async: true,
        success: function( xmlResponse ) {
            // get the contents from search data
            isfetched = true;
            $('.popup').detach().appendTo('.header-inner');
            var datas = $( "entry", xmlResponse ).map(function() {
                return {
                    title: $( "title", this ).text(),
                    content: $("content",this).text(),
                    url: $( "url" , this).text()
                };
            }).get();
            var $input = document.getElementById(search_id);
            var $resultContent = document.getElementById(content_id);
            $input.addEventListener('input', function(){
                var matchcounts = 0;
                var str='<ul class=\"search-result-list\">';
                var keywords = this.value.trim().toLowerCase().split(/[\s\-]+/);
                $resultContent.innerHTML = "";
                if (this.value.trim().length > 1) {
                // perform local searching
                datas.forEach(function(data) {
                    var isMatch = false;
                    var content_index = [];
                    var data_title = data.title.trim().toLowerCase();
                    var data_content = data.content.trim().replace(/<[^>]+>/g,"").toLowerCase();
                    var data_url = data.url;
                    var index_title = -1;
                    var index_content = -1;
                    var first_occur = -1;
                    // only match artiles with not empty titles and contents
                    if(data_title != '') {
                        keywords.forEach(function(keyword, i) {
                            index_title = data_title.indexOf(keyword);
                            index_content = data_content.indexOf(keyword);
                            if( index_title >= 0 || index_content >= 0 ){
                                isMatch = true;
								if (i == 0) {
                                    first_occur = index_content;
                                }
                            } 
							
                        });
                    }
                    // show search results
                    if (isMatch) {
                        matchcounts += 1;
                        str += "<li><a href='"+ data_url +"' class='search-result-title'>"+ data_title +"</a>";
                        var content = data.content.trim().replace(/<[^>]+>/g,"");
                        if (first_occur >= 0) {
                            // cut out 100 characters
                            var start = first_occur - 20;
                            var end = first_occur + 80;
                            if(start < 0){
                                start = 0;
                            }
                            if(start == 0){
                                end = 50;
                            }
                            if(end > content.length){
                                end = content.length;
                            }
                            var match_content = content.substring(start, end);
                            // highlight all keywords
                            keywords.forEach(function(keyword){
                                var regS = new RegExp(keyword, "gi");
                                match_content = match_content.replace(regS, "<b class=\"search-keyword\">"+keyword+"</b>");
                            });

                            str += "<p class=\"search-result\">" + match_content +"...</p>"
                        }
                        str += "</li>";
                    }
                })};
                str += "</ul>";
                if (matchcounts == 0) { str = '<div id="no-result"><i class="fa fa-frown-o fa-5x" /></div>' }
                if (keywords == "") { str = '<div id="no-result"><i class="fa fa-search fa-5x" /></div>' }
                $resultContent.innerHTML = str;
            });
            proceedsearch();
        }
    });}

    // handle and trigger popup window;
    $('.popup-trigger').click(function(e) {
      e.stopPropagation();
      if (isfetched == false) {
        searchFunc(path, 'local-search-input', 'local-search-result');
      } else {
        proceedsearch();
      };

    });

    $('.popup-btn-close').click(function(e){
      $('.popup').hide();
      $(".popoverlay").remove();
      $('body').css('overflow', '');
    });
    $('.popup').click(function(e){
      e.stopPropagation();
    });
  </script>


  

  

  

  


</body>
</html>
